package com.ihisun.tmhcms.controller.usercontroller;

import com.ihisun.tmhcms.core.dto.userdto.SearchUserDto;
import com.ihisun.tmhcms.core.dto.userdto.VipLevelTotalDto;
import com.ihisun.tmhcms.core.service.userservice.UserService;
import com.ihisun.tmhcms.core.vo.UserVo;
import com.ihisun.tmhcms.utils.ResponseVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = "用户相关Api")
@RestController
@RequestMapping("user")
public class UserController {

    @Resource
    UserService userService;

    @GetMapping("/userRoleNumber")
    @ApiOperation(value = "查询各等级会员数量",response = VipLevelTotalDto.class)
    public ResponseVo userRoleNumber() {
        return userService.countByVipNum();
    }
    @PostMapping("/searchUser")
    @ApiOperation(value = "会员列表",response = UserVo.class)
    public ResponseVo searchUser(@RequestBody SearchUserDto searchUserDto){
        return userService.searchUser(searchUserDto);
    }
    @GetMapping("/userInfo")
    @ApiOperation(value = "用户详情",response = UserVo.class)
    @ApiImplicitParam(name = "uuid",value = "用户uuid",dataType = "String" ,paramType = "query")
    public ResponseVo userInfo(String uuid){
        return userService.userInfo(uuid);
    }

    @GetMapping("/updateRole")
    @ApiOperation(value = "修改会员等级")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uuid",value = "用户uuid",dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "role",value = "等级",dataType = "String", paramType = "query")
    })
    public ResponseVo updateRole(String uuid,String role){

        return userService.updateRole(uuid,role);
    }

}
